package demo2;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-11-02
 * Time:20:21
 */
/*
反射 + 枚举 + lambada
反射：能知道你当前类内部的细节
运行期间 获取类型的信息
反射中重要的四个类
Class类：代表类的实体，在运行的java应用程序中表示类和接口
Filed类：代表类型的成员变量/类的属性
Method类：代表类的方法
Constructor类:代表类的构造方法
 */

    class  Student{
        private String name = "bit";
        public int age = 18;
        public Student(){
            System.out.println("Student()");
        }
        private Student(String name,int age){
            this.name = name;
            this.age = age;
            System.out.println("Student(String,name)");
        }
        private void eat(){
            System.out.println("i am eat");
        }

        public void sleep(){
            System.out.println("i am pig");
        }
        private void function(String str){
            System.out.println(str);
        }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class TestDemo {
    public static void main(String[] args) {
        Class<?> c1 = null;
        try {
            c1 = Class.forName("demo2.Student");
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }
        Class<?> c2 =  Student.class;
        Student student = new Student();
        Class<?> c3 =student.getClass();
/*
一个类对应一个class对象
所以全部为true
 */
        System.out.println(c1 == c2);
        System.out.println(c2 == c3);
        System.out.println(c1 == c3);
    }
}
